<div [@routerTransition]>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>编码规则管理</span>
                </h3>
                <span class="m-section__sub">
                    生成编码规则管理
                </span>
            </div>
            <div class="col text-right mt-3 mt-md-0">
                <button (click)="createCodeRule()" *ngIf="isGranted('Pages.CodeManage.Create')" class="btn btn-primary">
                    <i class="fa fa-plus"></i> 添加对象
                </button>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile" style="margin: 0;">
            <div class="m-portlet__body" style="height: 724px;">
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12" style="padding: 0;">
                                <div class="form-group m-form__group align-items-center">
                                    <div class="input-group">
                                        <input [(ngModel)]="filterText" name="filterText" autoFocus
                                               class="form-control m-input" [placeholder]="l('SearchWithThreeDot')"
                                               type="text">
                                        <span class="input-group-btn">
                                            <button (click)="getCodeRules()" class="btn btn-primary" type="submit">
                                                <i class="flaticon-search-1"
                                                   [attr.aria-label]="l('Search')"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table #dataTable (onLazyLoad)="getCodeRules($event)" [value]="primengTableHelper.records"
                                 rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                                 [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
                                 [resizableColumns]="primengTableHelper.resizableColumns">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 130px"
                                        [hidden]="!isGrantedAny('Pages.Administration.Users.Impersonation', 'Pages.Administration.Users.Edit', 'Pages.Administration.Users.ChangePermissions', 'Pages.Administration.Users.Delete')">
                                        {{'Actions' | localize}}
                                    </th>
                                    <th style="width: 100px">
                                        序号
                                    </th>
                                    <th style="width: 150px">
                                        对象编号
                                    </th>
                                    <th style="width: 150px">
                                        对象名称
                                    </th>
                                    <th style="width: 150px">
                                        规则方式
                                    </th>
                                    <th style="width: 150px">
                                        当前流水号
                                    </th>
                                    <th style="width: 200px">
                                        备注
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit" let-ri='rowIndex'>
                                <tr>
                                    <td style="width: 130px"
                                        [hidden]="!isGrantedAny('Pages.CodeManage', 'Pages.CodeManage.Edit')">
                                        <div class="btn-group dropdown" dropdown container="body">
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span>
                                                {{"Actions" | localize}}
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <!-- *ngIf="'Pages.Tasks.Edit' | permission"   *ngIf="'Pages.Tasks.Delete' | permission"-->
                                                    <a href="javascript:;"
                                                       (click)="createoreditcoderulemodal.show(record.id)">{{'Edit' | localize}}</a>
                                                </li>
                                                <li>
                                                    <a href="javascript:;"
                                                       (click)="deletecoderule(record)">{{'Delete' | localize}}</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <th style="width: 100px">
                                        {{ri+1}}
                                    </th>
                                    <td style="width: 150px">
                                        {{record.enCode}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.fullName}}
                                    </td>
                                    <td style="width: 150px">
                                        自动
                                    </td>
                                    <td style="width: 150px">
                                        {{record.currentNumber}}
                                    </td>
                                    <td style="width: 200px">
                                        {{record.description}}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{'NoData' | localize}}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                         (onPageChange)="getCodeRules($event)"
                                         [totalRecords]="primengTableHelper.totalRecordsCount"
                                         [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

                            </p-paginator>
                            <span class="total-records-count">
                                {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>


    <createoreditcoderulemodal #createoreditcoderulemodal (modalSave)="getCodeRules()"></createoreditcoderulemodal>
</div>
